﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Runtime.InteropServices;

namespace DCSoft.TemperatureChart
{
    /// <summary>
    /// 测量点的值
    /// </summary>
    /// <remarks>编制 袁永福</remarks>
    [Serializable]
    [ComVisible(false)]
    public class FooterMeasure
    {
        /// <summary>
        /// 初始化对象
        /// </summary>
        public FooterMeasure()
        {
        }

        private string _RecordID = null;
        /// <summary>
        /// 记录编号
        /// </summary>
        [DefaultValue( null )]
        public string RecordID
        {
            get
            {
                return _RecordID; 
            }
            set
            {
                _RecordID = value; 
            }
        }

        private string _Pee = null;
        /// <summary>
        /// 尿量
        /// </summary>
        [DefaultValue( null )]
        public string Pee
        {
            get
            {
                return _Pee; 
            }
            set
            {
                _Pee = value; 
            }
        }

        private string _Stool = null;
        /// <summary>
        /// 大便次数
        /// </summary>
        [DefaultValue( null )]
        public string Stool
        {
            get
            {
                return _Stool; 
            }
            set
            {
                _Stool = value; 
            }
        }

        private string _Liquid_In = null;
        /// <summary>
        /// 液体进量
        /// </summary>
        [DefaultValue( null )]
        public string Liquid_In
        {
            get { return _Liquid_In; }
            set { _Liquid_In = value; }
        }

        private string _Liquid_Out = null;
        /// <summary>
        /// 液体出量
        /// </summary>
        [DefaultValue( null )]
        public string Liquid_Out
        {
            get { return _Liquid_Out; }
            set { _Liquid_Out = value; }
        }

        private string _Blood_PressureA = null;
        /// <summary>
        /// A血压
        /// </summary>
        [DefaultValue( null )]
        public string Blood_PressureA
        {
            get { return _Blood_PressureA; }
            set { _Blood_PressureA = value; }
        }

        private string _Blood_PressureP = null;
        /// <summary>
        /// P血压
        /// </summary>
        [DefaultValue( null )]
        public string Blood_PressureP
        {
            get { return _Blood_PressureP; }
            set { _Blood_PressureP = value; }
        }

        private string _Body_Weight = null;
        /// <summary>
        /// 体重
        /// </summary>
        [DefaultValue( null )]
        public string Body_Weight
        {
            get { return _Body_Weight; }
            set { _Body_Weight = value; }
        }

        private string _Abdomen_Circumference = null;
        /// <summary>
        /// 腹围
        /// </summary>
        [DefaultValue( null )]
        public string Abdomen_Circumference
        {
            get { return _Abdomen_Circumference; }
            set { _Abdomen_Circumference = value; }
        }

        private DateTime _ValueDate = TemperatureDocument.NullDate;
        /// <summary>
        /// 测量日期
        /// </summary>
        [DefaultValue( typeof( DateTime ) , TemperatureDocument.NullDateString )]
        public DateTime ValueDate
        {
            get
            {
                return _ValueDate.Date ; 
            }
            set
            {
                _ValueDate = value.Date ; 
            }
        }

        private DataRowState _RecordState = DataRowState.Unchanged;
        /// <summary>
        /// 记录状态
        /// </summary>
        [Browsable( false )]
        [System.Xml.Serialization.XmlIgnore]
        public DataRowState RecordState
        {
            get { return _RecordState; }
            set { _RecordState = value; }
        }

        /// <summary>
        /// 设置默认值
        /// </summary>
        public void SetDefaultValue()
        {
            this._Abdomen_Circumference = "80CM";
            this._Blood_PressureA = "90";
            this._Blood_PressureP = "90";
            this._Body_Weight = "80";
            this._Liquid_In = "1000";
            this._Liquid_Out = "1000";
            this._Pee = "100";
            this._Stool = "100";
        }

        /// <summary>
        /// 复制对象
        /// </summary>
        /// <returns>复制品</returns>
        public FooterMeasure Clone()
        {
            return (FooterMeasure)this.MemberwiseClone();
        }
    }

    /// <summary>
    /// 数据记录列表
    /// </summary>
    /// <remarks>编制 袁永福</remarks>
    [ComVisible(false)]
    public class FooterMeasureList : List<FooterMeasure>
    {
        /// <summary>
        /// 初始化对象
        /// </summary>
        public FooterMeasureList()
        {
        }

        /// <summary>
        /// 深度复制
        /// </summary>
        /// <returns>复制品</returns>
        public FooterMeasureList CloneDeeply()
        {
            FooterMeasureList list = new FooterMeasureList();
            foreach (FooterMeasure m in this)
            {
                list.Add(m.Clone());
            }
            return list;
        }
    }

    internal class CMeasureComparer :IComparer<FooterMeasure>
    {
        public int Compare(FooterMeasure x, FooterMeasure y)
        {
            return DateTime.Compare(x.ValueDate, y.ValueDate);
        }
    }
}
